package ru.alperez.util;

public class NmeaParser {
	public static String getField(String nmeaString, int nField) {
		if (nmeaString == null) return "";
		int startPos=0, endPos=0;
		int pos;
		int n=0;
		while((pos=nmeaString.indexOf(',', startPos)) >= 0) {
			startPos = pos + 1;
			if (++n == nField) {
				if ((endPos = nmeaString.indexOf(',', startPos)) >= 0) {
					return nmeaString.substring(startPos, endPos);
				}
			}
		}
		return "";
	}
}
